A few months ago, when our projects were still in .NET 4.7.2, we used to run unit tests on our Azure DevOps Server using the Visual Studio Test task. We used parameter Test files to specify which test assemblies need to run and Code Coverage worked just fine there.
Since we migrated our projects to .NET 5.0, we use dotnet test to run unit tests and now Code Coverage doesn't work anymore.
Here's an example:
D:\test-2-1\_tool\dotnet\dotnet.exe test A.Test.dll B.Test.dll C.Test.dll --logger trx --results-directory D:\test-2-1\_temp --settings D:\test-2-1\5\s\.runsettings
Microsoft (R) Test Execution Command Line Tool Version 16.9.4
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 22 test files matched the specified pattern.
Data collection : Unable to find a datacollector with friendly name 'Code Coverage'.
Data collection : Could not find data collector 'Code Coverage'
Content of .runsettings
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>
<ModulePaths>
<Include>
<ModulePath>{someRegexToLimitCodeCoverageToSpecificTestAssemblies}</ModulePath>
</Include>
</ModulePaths>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
In another smaller project, Code Coverage still works, but here we specify which project files should be tested, rather than which compiled test assemblies.
Is this the way to go now and if yes, is it possible to get it back to work with specifying test assemblies too?
Thanks in advance!